package com.googlecode.garbagecan.dbtest.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateTimeUtil {
	
	public static DateFormat DATETIME_LONG_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
	public static DateFormat DATETIME_SHORT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public static DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
	public static DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss");

	public Date parse(String s, DateFormat df) {
		try {
			return df.parse(s);
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
	}
	
	public String format(Date date, DateFormat df) {
		return df.format(date);
	}
}
